﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FacebookTest.aspx.cs" Inherits="Facebook.Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form2" runat="server">
    <div id="fb-root">
    </div>
    <script type="text/javascript">
        function myfunction() {
            window.fbAsyncInit = function () {
                FB.init({
                    appId: '131174487000096', // App ID
                    channelUrl: 'http://connect.facebook.net/en_US/all.js', // Channel File
                    status: true, // check login status
                    cookie: true, // enable cookies to allow the server to access the session
                    xfbml: true  // parse XFBML
                });
                FB.login(function (response) {
                    if (response.authResponse) {
                        console.log('Welcome!  Fetching your information.... ');
                        FB.api('/me', function (response) {
                            console.log('Good to see you, ' + response.name + '.');
                            document.getElementById("imgConnect").style.display = "none";
                            document.getElementById("imgUser").src = "https://graph.facebook.com/" + response.id + "/picture";
                            document.getElementById("spUserName").innerHTML = response.id + "<BR />" + response.name + "<BR />" + response.first_name + "<BR />" + response.middle_name + "<BR />" + response.last_name + "<BR />" + response.gender + "<BR />" + response.locale + "<BR />" + response.languages + "<BR />" + response.link + "<BR />" + response.username + "<BR />" + response.third_party_id + "<BR />" + response.timezone + "<BR />" + response.updated_time + "<BR />" + response.verified + "<BR />" + response.bio + "<BR />" + response.birthday + "<BR />" + response.education + "<BR />" + response.email + "<BR />" + response.hometown + "<BR />" + response.interested_in + "<BR />" + response.location + "<BR />" + response.political + "<BR />" + response.favorite_athletes + "<BR />" + response.favorite_teams + "<BR />" + response.quotes + "<BR />" + response.relationship_status + "<BR />" + response.religion + "<BR />" + response.significant_other + "<BR />" + response.video_upload_limits + "<BR />" + response.website + "<BR />" + response.work + "<BR />"
                            FB.logout(function (response) {
                                document.getElementById("imgConnect").style.display = "";
                                console.log('Logged out.');
                            });
                        });
                    } else {
                        console.log('User cancelled login or did not fully authorize.');
                    }
                }, { scope: 'email' });
            };
            // Load the SDK Asynchronously
            (function (d) {
                var js, id = 'facebook-jssdk'; if (d.getElementById(id)) { return; }
                js = d.createElement('script'); js.id = id; js.async = true;
                js.src = "//connect.facebook.net/en_US/all.js";
                d.getElementsByTagName('head')[0].appendChild(js);
            } (document));
        }
    </script>
    <div style="height: 50px;">
    </div>
    <img id="imgConnect" src="http://footballawi.com/images/facbook.png" alt="footballawi.com" onclick="myfunction()"
        style="cursor: pointer" />
    <img alt="" src="" id="imgUser" />
    <br />
    <span id="spUserName"></span>
    </form>
</body>
</html>
